﻿@addTagHelper *, WebVella.Erp.Plugins.Core
@addTagHelper *, WebVella.Erp.Web
@addTagHelper *, WebVella.TagHelpers
@using WebVella.Erp.Web.Utils;
@using WebVella.Erp.Web.Components;
@using WebVella.Erp.Web.Models;
@using WebVella.Erp.Api.Models;
@using WebVella.TagHelpers.Models;
@{
	var options = (PcGrid.PcGridOptions)ViewBag.Options;
	var node = (PageBodyNode)ViewBag.Node;
	var pager = (int)ViewBag.Page;
	var totalCount = (int)ViewBag.TotalCount;
	var pageSize = (int)ViewBag.PageSize;
	var records = (List<EntityRecord>)ViewBag.Records;
	var columns = (List<WvGridColumnMeta>)ViewBag.Columns;
}
<div class="p-1">
	<wv-grid striped="@options.Striped" small="@options.Small" bordered="@options.Bordered" borderless="@options.Borderless"
		hover="@options.Hover" responsive-breakpoint="@options.ResponsiveBreakpoint" id="@options.Id" prefix="@options.Prefix"
		name="@options.Name" culture="@options.Culture" class="@options.Class" query-string-sortby="@options.QueryStringSortBy" 
		query-string-sort-order="@options.QueryStringSortOrder" query-string-page="@options.QueryStringPage" columns="columns"
		page="@pager" page-size="@pageSize" total-count="@totalCount" has-thead="@options.HasThead" has-tfoot="@options.HasTfoot">
		<wv-grid-row>
			@if (options.VisibleColumns > 0)
			{
				var columnWidth = options.HasThead ? "" : columns[0].Width;
				<wv-grid-column width="@columnWidth" class="@options.Container1Class" vertical-align="@options.Container1VerticalAlign" horizontal-align="@options.Container1HorizontalAlign">
					<wv-pb-node-container parent-node-id="@node.Id" container-id="@options.Container1Id"></wv-pb-node-container>
				</wv-grid-column>
			}
			@if (options.VisibleColumns > 1)
			{
				var columnWidth = options.HasThead ? "" : columns[1].Width;
				<wv-grid-column width="@columnWidth" class="@options.Container2Class" vertical-align="@options.Container2VerticalAlign" horizontal-align="@options.Container2HorizontalAlign">
					<wv-pb-node-container parent-node-id="@node.Id" container-id="@options.Container2Id"></wv-pb-node-container>
				</wv-grid-column>
			}
			@if (options.VisibleColumns > 2)
			{
				var columnWidth = options.HasThead ? "" : columns[2].Width;
				<wv-grid-column width="@columnWidth" class="@options.Container3Class" vertical-align="@options.Container3VerticalAlign" horizontal-align="@options.Container3HorizontalAlign">
					<wv-pb-node-container parent-node-id="@node.Id" container-id="@options.Container3Id"></wv-pb-node-container>
				</wv-grid-column>
			}
			@if (options.VisibleColumns > 3)
			{
				var columnWidth = options.HasThead ? "" : columns[3].Width;
				<wv-grid-column width="@columnWidth" class="@options.Container4Class" vertical-align="@options.Container4VerticalAlign" horizontal-align="@options.Container4HorizontalAlign">
					<wv-pb-node-container parent-node-id="@node.Id" container-id="@options.Container4Id"></wv-pb-node-container>
				</wv-grid-column>
			}
			@if (options.VisibleColumns > 4)
			{
				var columnWidth = options.HasThead ? "" : columns[4].Width;
				<wv-grid-column width="@columnWidth" class="@options.Container5Class" vertical-align="@options.Container5VerticalAlign" horizontal-align="@options.Container5HorizontalAlign">
					<wv-pb-node-container parent-node-id="@node.Id" container-id="@options.Container5Id"></wv-pb-node-container>
				</wv-grid-column>
			}
			@if (options.VisibleColumns > 5)
			{
				var columnWidth = options.HasThead ? "" : columns[5].Width;
				<wv-grid-column width="@columnWidth" class="@options.Container6Class" vertical-align="@options.Container6VerticalAlign" horizontal-align="@options.Container6HorizontalAlign">
					<wv-pb-node-container parent-node-id="@node.Id" container-id="@options.Container6Id"></wv-pb-node-container>
				</wv-grid-column>
			}
			@if (options.VisibleColumns > 6)
			{
				var columnWidth = options.HasThead ? "" : columns[6].Width;
				<wv-grid-column width="@columnWidth" class="@options.Container7Class" vertical-align="@options.Container7VerticalAlign" horizontal-align="@options.Container7HorizontalAlign">
					<wv-pb-node-container parent-node-id="@node.Id" container-id="@options.Container7Id"></wv-pb-node-container>
				</wv-grid-column>
			}
			@if (options.VisibleColumns > 7)
			{
				var columnWidth = options.HasThead ? "" : columns[7].Width;
				<wv-grid-column width="@columnWidth" class="@options.Container8Class" vertical-align="@options.Container8VerticalAlign" horizontal-align="@options.Container8HorizontalAlign">
					<wv-pb-node-container parent-node-id="@node.Id" container-id="@options.Container8Id"></wv-pb-node-container>
				</wv-grid-column>
			}
			@if (options.VisibleColumns > 8)
			{
				var columnWidth = options.HasThead ? "" : columns[8].Width;
				<wv-grid-column width="@columnWidth" class="@options.Container9Class" vertical-align="@options.Container9VerticalAlign" horizontal-align="@options.Container9HorizontalAlign">
					<wv-pb-node-container parent-node-id="@node.Id" container-id="@options.Container9Id"></wv-pb-node-container>
				</wv-grid-column>
			}
			@if (options.VisibleColumns > 9)
			{
				var columnWidth = options.HasThead ? "" : columns[9].Width;
				<wv-grid-column width="@columnWidth" class="@options.Container10Class" vertical-align="@options.Container10VerticalAlign" horizontal-align="@options.Container10HorizontalAlign">
					<wv-pb-node-container parent-node-id="@node.Id" container-id="@options.Container10Id"></wv-pb-node-container>
				</wv-grid-column>
			}
			@if (options.VisibleColumns > 10)
			{
				var columnWidth = options.HasThead ? "" : columns[10].Width;
				<wv-grid-column width="@columnWidth" class="@options.Container11Class" vertical-align="@options.Container11VerticalAlign" horizontal-align="@options.Container11HorizontalAlign">
					<wv-pb-node-container parent-node-id="@node.Id" container-id="@options.Container11Id"></wv-pb-node-container>
				</wv-grid-column>
			}
			@if (options.VisibleColumns > 11)
			{
				var columnWidth = options.HasThead ? "" : columns[11].Width;
				<wv-grid-column width="@columnWidth" class="@options.Container12Class" vertical-align="@options.Container12VerticalAlign" horizontal-align="@options.Container12HorizontalAlign">
					<wv-pb-node-container parent-node-id="@node.Id" container-id="@options.Container12Id"></wv-pb-node-container>
				</wv-grid-column>
			}
		</wv-grid-row>
	</wv-grid>
</div>